﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Emporium_Web.Enums;

namespace Emporium_Web
{
    public partial class Menu : System.Web.UI.MasterPage
    {
        private Dictionary<string, string> Breadcrumbs
        {
            set { Session["Breadcrumbs"] = value; }
            get { return (Dictionary<string, string>)Session["Breadcrumbs"]; }
        }

        public void AgregarBreadcrumb(string titulo, string url, bool reiniciar)
        {
            if (reiniciar)
            {
                Breadcrumbs = new Dictionary<string, string>();
            }

            Breadcrumbs.Add(titulo, url);

            breadcrumb.Text = "<ul id=\"breadcrumb\">";

            foreach (var item in Breadcrumbs)
            {
                breadcrumb.Text += "<li><a href=\"" + item.Value + "\" title=\"" + item.Key + "\">" + item.Key + "</a></li>";
            }

            breadcrumb.Text += "</ul>";
        }

        public void ActualizaMenu(MenuPrincipal menuPrincipal, int menuSecundario)
        {
            switch (menuPrincipal)
            {
                case MenuPrincipal.Generales:
                    liGenerales.Attributes["class"] = liGenerales.Attributes["class"] + " current";
                    liGenClientes.Attributes["class"] = "current";
                    break;
                case MenuPrincipal.Comercial:
                    liLogistica.Attributes["class"] = liLogistica.Attributes["class"] + " current";
                    liLogPedidosCompra.Attributes["class"] = "current";
                    break;
                case MenuPrincipal.Desarrollo:
                    liDesarrollo.Attributes["class"] = liDesarrollo.Attributes["class"] + " current";
                    switch ((MenuDesarrollo)menuSecundario)
                    {
                        case MenuDesarrollo.Estilo:
                            liDesEstilo.Attributes["class"] = "current";
                            break;
                        case MenuDesarrollo.RutaProduccion:
                            liDesRutaProduccion.Attributes["class"] = "current";
                            break;
                    }
                    break;
                case MenuPrincipal.Produccion:
                    liProduccion.Attributes["class"] = liProduccion.Attributes["class"] + " current";
                    switch ((MenuProduccion)menuSecundario)
                    {
                        case MenuProduccion.OrdenProduccion:
                            liProdOrdenProduccion.Attributes["class"] = "current";
                            break;
                        case MenuProduccion.OrdenCorte:
                            liPrdoOrdenCorte.Attributes["class"] = "current";
                            break;
                        case MenuProduccion.AvanceActividades:
                            liAvanceActividades.Attributes["class"] = "current";
                            break;
                        case MenuProduccion.ConsultaAvanceActividades:
                            liConsultaAvanceActividades.Attributes["class"] = "current";
                            break;
                        case MenuProduccion.PackingList:
                            liPackingList.Attributes["class"] = "current";
                            break;
                    }
                    break;

                default:
                    break;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] != null)
                txtUsuario.Text = Session["UserName"].ToString();
        }
    }
}